<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>InputEx - using XML, example with RSS</title>	

<!-- YUI CSS -->
<link rel="stylesheet" type="text/css" href="../lib/yui/reset/reset-min.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/fonts/fonts-min.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/container/assets/container.css"> 
<link rel="stylesheet" type="text/css" href="../lib/yui/assets/skins/sam/skin.css">

<!-- InputEx CSS -->
<link type='text/css' rel='stylesheet' href='../css/inputEx.css' />

<!-- Demo CSS -->
<link rel="stylesheet" type="text/css" href="css/demo.css"/>
<link rel="stylesheet" type="text/css" href="css/dpSyntaxHighlighter.css">
	
<script src="../lib/yui/utilities/utilities.js"></script>
<script src="../lib/XML/ObjTree.js"></script>
<script src="../build/inputex.js"></script>

</head>
<body>
	
	<div id="formContainer" class='exampleDiv'></div>
	
<script>

// Required for the UrlField and ListField
YAHOO.inputEx.spacerUrl = "../images/space.gif";

var rssFormDef = {
	type: 'group',
	
	inputParams: {
		parentEl: 'formContainer',
		fields: [
			{type: 'number', inputParams: {label: 'Version', name: '-version'} },
			{type: 'group', inputParams: {
				name: 'channel',
				fields: [
					{type: 'string', inputParams: {label: 'Title', name: 'title'}},
					{type: 'string', inputParams: {label: 'Description', name: 'description'}},
					{type: 'url', inputParams: {label: 'Link', name: 'link'}},
					{type: 'select', inputParams: {label: 'Language', name: 'language', selectValues: ['en', 'fr']}},
					{type: 'list', inputParams: {name: 'item', useButtons: true, elementType:{
						type: 'group',
						inputParams: {
							fields: [
								{type: 'string', inputParams: {label: 'Title', name: 'title'}},
								{type: 'string', inputParams: {label: 'Description', name: 'description'}},
								{type: 'string', inputParams: {label: 'Link', name: 'link'}}
							]
						}
					}}}
				]
			}}
		]
	}
};


YAHOO.util.Event.addListener(window, "load", function() {
	
		var rssForm = inputEx(rssFormDef);
		
		// Get the rss and populate the form
		YAHOO.util.Connect.asyncRequest('GET', 'rss-example.xml', {
			success: function(o) {
				var xotree = new XML.ObjTree();
			  var tree = xotree.parseXML( o.responseText );
				console.log(tree);
				rssForm.setValue(tree.rss);
			}
		});
   
});
</script>
</body>
</html>
